﻿using System;
using System.Net.Sockets;

namespace ServerFrame
{
	public class MyToken
	{
		public SocketAsyncEventArgs read_args,write_args;

		public Socket socket;

		public MyToken ()
		{
			read_args = new SocketAsyncEventArgs ();
			write_args = new SocketAsyncEventArgs ();

			read_args.UserToken = this;
			write_args.UserToken = this;

		}


		public void Close(){
			try
			{
				socket.Shutdown(SocketShutdown.Both);
				socket.Close();
				socket=null;
			}
			// throws if client process has already closed
			catch (Exception ex) { 
				Console.WriteLine (ex.ToString ());
			}

		}


	}
}

